import { Camera, Intersection, Object3D, Object3DEventMap, Vector2 } from "three";
import { ThreeCore } from "../three/core";


export class BaseRaycaster {
    private threeCore = new ThreeCore();
    private raycaster;

    constructor() {
        this.raycaster = this.threeCore.raycaster();
    }

    setFromCamera(coords: Vector2, camera: Camera) {
        this.raycaster.setFromCamera(coords, camera);
    }

    intersectObjects(object: Object3D<Object3DEventMap>[]): Intersection<Object3D<Object3DEventMap>> {
        const intersects = this.raycaster.intersectObjects(object);
        return intersects.length > 0 ? intersects[0] : <any>{};
    }
}